
# 1.导包
from haystack import indexes
from apps.goods.models import SKU

# 2.继承
class SKUIndex(indexes.SearchIndex,indexes.Indexable):
    # 3.字段的模板文件关联
    text = indexes.CharField(document=True,use_template=True)

    # 4.get_model()
    def get_model(self):
        return SKU

    # 5.index_queryset()
    def index_queryset(self, using=None):
        return self.get_model().objects.filter(is_launched=True)
